//
//  GROederDetailHeaderCell.m
//  YC_GRice
//
//  Created by luojinrong11 on 2018/7/21.
//  Copyright © 2018年 YeCai. All rights reserved.
//

#import "GROederDetailHeaderCell.h"

@implementation GROederDetailHeaderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self.leftBtF.layer setBorderWidth:1];
    [self.leftBtF.layer setBorderColor:HEXCOLOR(0xDDDDDD).CGColor];
    [self.leftBtT.layer setBorderColor:[HEXCOLOR(0xDDDDDD) CGColor]];
    [self.leftBtT.layer setBorderWidth:1];
    // Initialization code
}

-(void)setOrderListModel:(GROrderListModel *)orderListModel{
    //等待支付 取消订单 去支付（黄） 1
    //等待发货 联系客服 申请退款(黄) 3
    // 等待收货 申请退货 查询物流 确认收货(黄) 5
    // 已完成   申请退货 物流信息 评价（黄）9
    //  已取消 （订单未支付取消 ，订单退款申请中）10
    //
    _orderListModel = orderListModel;
    _lineView.hidden = NO;
    _leftBtT.hidden = NO;
    self.returnView.hidden = YES;
    [self.leftBtT.layer setBorderColor:[UIColor clearColor].CGColor];
    self.leftBtT.backgroundColor = HEXCOLOR(0xFBD62D);
    if (orderListModel.status == 9) {
        self.orderStatusLabel.text = @"感谢您对龟米的信任，期待再次购物";
    }else{
    self.contentStausLabel.text = _orderListModel.subTitle;
    self.orderStatusLabel.text = _orderListModel.mainTitle;
    }
    if (_orderListModel.status == 10) {
        _leftBtF.hidden = YES;
        _leftBtT.hidden = YES;
         _lineView.hidden = YES;
        if (_orderListModel.isRefund) {
            self.returnView.hidden = NO;
             _lineView.hidden = NO;
        }
    }else{
        if (_orderListModel.status == 1 ||_orderListModel.status == 3) {
            if (_orderListModel.status == 1) {
                [_leftBtF setTitle:@"取消订单" forState:UIControlStateNormal];
                  [_leftBtT setTitle:@"去支付" forState:UIControlStateNormal];
            }else{
                [_leftBtF setTitle:@"联系客服" forState:UIControlStateNormal];
                [_leftBtT setTitle:@"申请退款" forState:UIControlStateNormal];
            }
            
        }else{
            if (_orderListModel.status == 5) {
                [_leftBtF setTitle:@"查询物流" forState:UIControlStateNormal];
                [_leftBtT setTitle:@"确认收货" forState:UIControlStateNormal];
            }else{
                
                [_leftBtF setTitle:@"物流信息"  forState:UIControlStateNormal];
                [_leftBtT setTitle: ( _orderListModel.isComment?@"评价":@"已评价") forState:UIControlStateNormal];
                self.leftBtT.backgroundColor = _orderListModel.isComment?HEXCOLOR(0xFBD62D):HEXCOLOR(0xffffff);
                [ self.leftBtT.layer setBorderColor:_orderListModel.isComment?[UIColor clearColor].CGColor:HEXCOLOR(0xDDDDDD).CGColor];
            }
        }
    }
}

- (IBAction)orderAction:(UIButton *)sender {
    OrderActionType actionType = 10;
    if ([sender.titleLabel.text isEqualToString:@"评价"]) {
        actionType = OrderActionTypeComment;
    }else if ([sender.titleLabel.text isEqualToString:@"联系客服"]){
        actionType = OrderActionTypeCustomerService;
    }else if ([sender.titleLabel.text isEqualToString:@"取消订单"]){
        actionType = OrderActionTypeCancleOrder;
    }else if ([sender.titleLabel.text isEqualToString:@"申请退款"]){
        actionType = OrderActionTypeReturnMoeny;
    }else if ([sender.titleLabel.text isEqualToString:@"去付款"]||[sender.titleLabel.text isEqualToString:@"去支付"]){
        actionType = OrderActionTypePayOrder;
    }else if ([sender.titleLabel.text isEqualToString:@"确认收货"]){
        actionType = OrderActionTypeConfirmOrder;
    }else if ([sender.titleLabel.text isEqualToString:@"查询物流"]||[sender.titleLabel.text isEqualToString:@"物流信息"]){
        actionType = OrderActionTypeLogsticsProgress;
    }
    if (_delegate && [_delegate respondsToSelector:@selector(dealOrderWithActionType: OrderId:)]) {
        [_delegate dealOrderWithActionType:actionType OrderId:_orderListModel.orderId];
        
    }
}


- (IBAction)returnProgressAction:(id)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(skipToReturnProgress:IsReturnGood:)]) {
        [_delegate skipToReturnProgress:_orderListModel.orderId IsReturnGood:NO];
        
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
